// app.js
import Cache from "./utils/Cache"
App({
  onLaunch() {
    var that = this;
    let token = Cache.get('token');
    if(!token){
      wx.getSetting({
       success:res=>{
         if(res.authSetting['scope.userInfo']){
           wx.getUserInfo({
             success:res=>{
              console.log(res);
                // 登录
              wx.login({
      
            success: res => {
              wx.request({
              url: 'http://www.tp6.com/wxaizufang/wxlogin',
              data:{code:res.code},
               success:res=>{
               Cache.set('token',res.data.token);
        }
      })
  }
})

             }
           })
         }
       }
      })
 
    }
   
  },
  globalData: {
    userInfo: null
  }
})
